package ly.mp.cmc.controller;

import com.ly.mp.cmc.common.reponse.BaseResult;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

/**
 * @Author: ly-songpengfei
 * @Date: 2025/7/31 20:32
 * @Description: 测试架构
 * @Version: 1.0
 */
@RestController
@RequestMapping(value = "/test/", produces = {MediaType.APPLICATION_JSON_UTF8_VALUE})
public class TestController {

    /**
     * @Description 测试项目正常启动运行
     * @Param []
     * @Return java.lang.String
     * @Author ly-songpengfei
     * @Date 2025/8/5 11:45
     */
    @RequestMapping(value = "/hello", method = RequestMethod.GET)
    public String helle() {
        return "Hello Gradle!";
    }

    /**
     * @Description 测试全局异常处理
     * @Param []
     * @Return com.ly.mp.cmc.common.reponse.BaseResult
     * @Author ly-songpengfei
     * @Date 2025/8/5 11:46
     */
    @RequestMapping(value = "/ex", method = RequestMethod.GET)
    public BaseResult exe() {
        int i = 1 / 0;
        return new BaseResult();
    }

    /**
     * @Description 测试过滤器使用
     * @Param [request, id, name]
     * @Return java.lang.String
     * @Author ly-songpengfei
     * @Date 2025/8/5 18:21
     */
    @RequestMapping(value = "/reqParam", method = RequestMethod.GET)
    public String reqParam(HttpServletRequest request,
                           @RequestParam(required = false) String id,
                           @RequestParam(required = false) String name) {
        return id + name;
    }

}
